Repository navigation
Wrappers: export only from the DLL; optimize and section the release build - #94
Merged
Merged
Conversation
…build - src/wrappers/tslang_export.h exported every wrapper whenever _WIN32, though its comment said it was a no-op for the static library. The same objects went into TypeScriptDefaultLib.lib, so every program exported - and so kept - all the regexp_*, http_*, stdio_* wrappers, and wrote a .lib/.exp beside itself. Now only TSLANG_WRAPPERS_DLL exports; build_core.bat compiles the wrappers a second time with it for the DLL. The DLL export tables are unchanged (all four models, release and debug). - build_core.bat: release wrappers had no /O2 at all (cl then does not optimize). Now /O2 /Gy /Gw (debug /Gy /Gw), so each function is a COMDAT the linker can drop; /wd4710 /wd4711 keep /Wall from listing every inlining decision. - build.sh, build_android.bat: -ffunction-sections -fdata-sections, for the compiler's new --gc-sections link. With the compiler's matching change (function sections for lib.ts), a Windows -mm=own program using Map/sort/toString went from 831 KB to 437 KB; the default library's share from ~500 KB to ~32 KB. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
src/wrappers/tslang_export.hmade every wrapper__declspec(dllexport)whenever_WIN32, though its comment said it was a no-op for the static library. The same objects went intoTypeScriptDefaultLib.lib, so every program exported, and therefore kept, allregexp_*,http_*andstdio_*wrappers, and wrote a.lib/.expnext to itself./MT /std:c++latestonly, with no/O2, so cl did not optimize them at all.Changes
tslang_export.h: exports only underTSLANG_WRAPPERS_DLL.build_core.batcompiles the wrappers a second time with it, into<lib>\dll_wrappers, for the DLL link. The DLL export tables are unchanged (diffed, all four models, release and debug).build_core.bat: release/O2 /Gy /Gw /wd4710 /wd4711, debug/Gy /Gw. The/wdflags stop/Wallfrom listing every inlining decision.build.sh,build_android.bat:-ffunction-sections -fdata-sections, for the compiler's new--gc-sectionslink.With ASDAlexander77/TypeScriptCompiler binary-size (function sections for
lib.ts), a Windows-mm=own --optprogram using Map/sort/toString went from 831 KB to 437 KB. The library's share went from ~500 KB to ~32 KB.Tests
tests.ps1, all four models × release/debug × compile/jit: all pass, declarations match.tests.shin WSL: all pass exceptweakref_basicgc release, which fails on every run with the locally built libgc.a.🤖 Generated with Claude Code